#ifndef _LIBRARYINTERFACE_H
#define _LIBRARYINTERFACE_H
#include ".\allegro\include\allegro.h"
#include "Sprite.h"
#include "SpriteAnimation.h"
#include "Timer.h"
#include <map>
#include <string>



#define BLACK makecol(0,   0,   0)
#define WHITE makecol(255, 255, 255)
#define RED	  makecol(255, 0,   0)
#define GREEN makecol(0,   255, 0)
#define BLUE  makecol(0,   0,   255)






class LibraryInterface{
public:
		LibraryInterface();					//constructor
		~LibraryInterface();				//destructor
		
		static bool Initialize();			//initialization routine
		static bool LoadSprite(unsigned int sprite_number);	//add a sprite to the sprite map
		static void PreOnFrameUpdate();		//delay execution for the desired program speed
		static bool Update();				//update routine
		static unsigned int PostOnFrameUpdate();	//keep track of the FPS (calculate every frame)
        static bool Blit(Sprite* s);        //blit a sprite
		
        static bool Blit(SpriteAnimation* a); //determine the correct frame to blit to the buffer
		static bool Render();				//copy the backbuffer to the screen
		static bool Deinitialize();			//deinitialization routine
		
		static void Print(char* output = "-", int x = 0, int y = 0);
		static void Print(int   output = 0, int x = 0, int y = 0);
		static void Print(float output = 0.0f, int x = 0, int y = 0);
		static void Print(std::string output = "", int x = 0, int y = 0);


        static void DrawRect(unsigned int x, unsigned int y, unsigned int half_of_width, unsigned int half_of_height, int r = 127, int g = 127, int b = 127);
		static void DrawFilledRect(unsigned int x, unsigned int y, unsigned int half_of_width, unsigned int half_of_height, int r = 127, int g = 127, int b = 127);
        static void DrawCircle(unsigned int x, unsigned int y, unsigned int radius, int r = 127, int g = 127, int b = 127);
        static void DrawFilledCircle(unsigned int x, unsigned int y, unsigned int radius, int r = 127, int g = 127, int b = 127);

		static unsigned int GetFPS();		//returns t	he frames per second
		static void IncrementFrameTicks();	//increment the ticks since the start of this frame
		static void IncrementTotalTicks();	//increment the ticks since the start of the program
		static void Spin(unsigned int waiting_time = 1);	//rest/delay for a period of time
		static void PrintDebugInfo();		//print debug information
		static unsigned int GetFontSize();
		static void TerminateApplication();
		static APPLICATION_STATE GetApplicationState();
		static void SetApplicationState(APPLICATION_STATE application_state);
        

		static void DrawOutlines();
		
public:

		static BITMAP* buffer;	//the back-buffer
		static std::map <unsigned int, Sprite> spriteMap;	//dictionary of sprites
		
		static unsigned int FPS;		//current per second
		static volatile int frameTicks;	//ticks this frame
		static volatile int totalTicks;	//ticks since program start
		static unsigned int previousTotalTicks;	//total ticks last update
		static unsigned int frameCount;	//counts frames 0 - 60 in a second

		static APPLICATION_STATE applicationState;
		
		

};

#endif